#include <iostream>
#include <string>

extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}


int main() {
    std::string cmd = "a = 7 + 11";

    lua_State* L =luaL_newstate();
    int r = luaL_dostring(L, cmd.c_str());

    if (r == 0) {
        lua_getglobal(L, "a");
        if (lua_isnumber(L, -1)) {
            float a_in_cpp = (float)lua_tonumber(L, -1);
            std::cout << "a_in_cpp " << a_in_cpp << std::endl;
        }
    } else {
        std::string errormsg = lua_tostring(L, -1);
        std::cout << errormsg << std::endl;
    }
    lua_close(L);

    return 0;
}